<template>
  <div :style="{ width: props.width, height: props.height }">
    <div
      class="text-[white] flex items-center justify-around px-[10px] my-[20px]"
    >
      <div v-for="item in states.arrtData" :key="item.prop" class="text-center">
        {{ item.label }}
      </div>
    </div>
    <vue3-seamless-scroll
      :list="list"
      class="scroll"
      :step="0.5"
      :limitScrollNum="3"
      :copyNum="3"
    >
      <div
        v-for="(item, index) in list"
        :key="index"
        class="bgs text-[white] flex items-center justify-around px-[10px] my-[15px] text-[16px]"
      >
        <div
          class="text-center"
          v-for="(de, i) in states.arrtData"
          :key="de.prop"
        >
          {{ item[de.prop] }}
        </div>
      </div>
    </vue3-seamless-scroll>
  </div>
</template>

<script setup lang="ts">
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";
import { computed, onMounted, ref, watch } from "vue";
let props = defineProps({
  width: {
    type: String,
    default: "400px",
  },
  height: {
    type: String,
    default: "30px",
  },
  models: {
    type: Object,
    default: () => ({}),
  },
  responseData: {
    type: Object,
    default: () => ({}),
  },
});
const list = ref<any[]>([]);
const states = computed({
  get: () => props.models,
  set: () => {},
}) as any;

onMounted(() => {
  if (props.responseData && props.responseData.length > 0) {
    list.value = props.responseData as any;
  } else {
    list.value = states.value.list;
  }
});
watch(
  () => props.responseData,
  () => {
    if (props.responseData) {
      list.value = props.responseData as any;
    }
  },
  {
    deep: true,
  }
);
</script>

<style scoped lang="scss">
.scroll {
  height: calc(100% - 100px);
  width: 100%;
  overflow: hidden;
}

.toptitle {
  width: 100%;
  display: flex;
  background-color: gainsboro;
  margin-bottom: 10px;
  border: 2px solid gainsboro;
  background-color: transparent;
  color: white;
}
.item {
  width: 33.3%;
  border-right: 2px solid gainsboro;
  text-align: center;
}

.bgs {
  &:nth-child(2n + 1) {
    background-color: #162e6a;
  }
}
</style>
